package com.thinkgsp.jxc.report;

import java.util.ArrayList;
import java.util.List;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.thinkgsp.jxc.model.SalesStockOutBill;
import com.thinkgsp.jxc.service.BillService;

public class JasperBeanFactory {
	
	private static ApplicationContext context = null;
	
	public static List<SalesStockOutBill> generateSalesStockOutBill() {
		context = new ClassPathXmlApplicationContext("classpath:/applicationContext-resources.xml",
				 "classpath:/applicationContext-persistence.xml",
				 "classpath:/applicationContext-service.xml",
				 "classpath*:/applicationContext.xml",
				 "**/applicationContext*.xml");		
		
		List<SalesStockOutBill> bills = new ArrayList<SalesStockOutBill>();
		BillService billService =  (BillService)context.getBean("billService");
		SalesStockOutBill bill = (SalesStockOutBill)billService.getBill(1L);
		bills.add(bill);
		return bills;
	}	
	public static void main(String[] args) {
		System.out.println("test");
		try {
			List<SalesStockOutBill> bills = generateSalesStockOutBill();
			System.out.println(bills);
		} catch(Exception e) {
			e.printStackTrace();
		}
	}
}
